<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/page.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<title>友着</title>
</head>
<body>
	<jsp:include page="navigation.jsp"></jsp:include>
	<div class="container" style="margin-left: 190px;">
		<div class="topbar-inner">
			<div class="myhead">
				<span class="crumb-name">用户信息</span>
			</div>
		</div>
		<form id="pageForm" action="homeuserinfo" method="post">
			<div class="topbar-inner">
				<div class="search">
				
				</div>
			</div>
			<div style="margin: 20px 20px 20px 20px; text-align: center;">
				<table class="table table-bordered table-hover table-striped">
					<thead>
						<tr>
							<th>用户名</th>
							<th>真实姓名</th>
							<th>手机号</th>
							<th>头像</th>
							<th>等级</th>
							<th>经验值</th>
							<th>爱币</th>
							<th>昵称</th>
							<th>身份证</th>
							<th>生日</th>
							<th>年龄</th>
							<th>收入</th>
							<th>所在地</th>
							<th>性别</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${ list }" var="l">
							<tr>
								<td>${ l.user_name }</td>
								<td>${ l.real_name }</td>
								<td>${ l.mobile }</td>
								<td><c:if test="${ l.portrait != null }">
										<img src="http://139.196.188.251:8080/upload/origin/${ l.portrait }" width=100px />
									</c:if></td>
								<td>${ l.level }</td>
								<td>${ l.exp }</td>
								<td>${ l.point }</td>
								<td>${ l.appellation }</td>
								<td>${ l.idcard }</td>
								<td>${ l.birthday }</td>
								<td>${ l.age }</td>
								<td>${ l.income }</td>
								<td>${ l.location }</td>
								<td>${ l.gender }</td>
								<td> <a href="javascript:"
									onclick="toDetail(${ l.id })">查看详情</a>&emsp;|&emsp;
									<c:if test="${ l.is_home == 0 }">
<%-- 										<a href="javascript:" onclick="setHomepage(${ l.id }, '你确定要放在主页？')"> --%>
<%-- 											放在主页 <c:if test="${ l.is_home == 1 }">取消主页</c:if> --%>
<!-- 										</a> -->
									</c:if> <c:if test="${ l.is_home == 1 }">
										<a href="javascript:" onclick="setHomepage(${ l.id }, '你确定要取消放在主页？')">
											取消置顶</a>
											&emsp;|&emsp;
<%-- 										<a href="javascript:" onclick="showalert_add(${ l.id })"> --%>
<!-- 											置顶顺序</a>	 -->
									</c:if>
									</td>
							</tr>
						</c:forEach>

					</tbody>
				</table>
				<input type="hidden" value="${ page.pageCount }" id="pageCount"
					name="pageCount" /> <input type="hidden"
					value="${ page.pageIndex }" id="pageIndex" name="pageIndex" />
				<c:if test="${ page == null }">
					<div style="font-size: larger;">暂无数据</div>
				</c:if>
				<c:if test="${ page != null && page.pageCount > 1 }">
					<ul id="pagination" class="pagination">

					</ul>
					<script type="text/javascript">
						setPage(document.getElementById("pagination"),
								parseInt($("#pageCount").val()), parseInt($(
										"#pageIndex").val()));
					</script>
				</c:if>
			</div>
		</form>
	</div>
	
	<!-- 模态框（Modal） -->
	<input type="hidden" value="" id="userid">
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="myModalLabel">设置制定顺序</h4>
				</div>
				<div class="modal-body">
					
					<div style="width: 100%; height: 40px;">
						置顶顺序：<input type="text" id="modal_content" class="form-control" name="content" />
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-primary" onclick="toAdd()">提交</button>
				</div>
			</div>
		</div>
	</div>
	<!-- /.modal -->
	<script>
		$(function() {
			$('.submenu_7_2').addClass('submenu_native');
		});

		
		
		function toDetail(userid) {
			window.location.href = 'userdetail?userid='+ userid;
		}
		
		function showalert_add(userid) {
			$('#userid').val(userid);
			$("#myModal").modal('show');
		}
		
		function setHomepage(userid, message) {
			if (confirm(message)) {
				$.ajax({
					type : 'post',
					url : 'sethome',
					data : {id: userid},
					success : function(data) {
						console.log(data);
						if (data != null) {
							if (data.code == 0) {
								alert('操作成功！');
								window.location.reload();
							} else {
								alert(data.message);
							}
						}
					}
				});
			}
			
		}
		
		function toAdd() {
			var content = $('#modal_content').val();
			var id = $('#userid').val();
			if (content == '') {
				alert('内容不能为空！');
				return;
			}

			$.ajax({
				type : 'post',
				url : 'sethome',
				data : {
					id:id,
					content : content
				},
				success : function(data) {
					if (data != null) {
						if (data.code == 0) {
							alert('置顶成功！');
							window.location.reload();
						}else{
							alert('置顶失败！');
							window.location.reload();
						}
					}

				}
			});
		}
	</script>
</body>

</html>